import Vue from 'vue'
import * as types from './mutation-types'

export default {
    [types.SET_USER_NO_LIST](state, data) {
        state.usersList = JSON.parse(JSON.stringify(data));
    },



    
    [types.STORE_INIT](state) {
        initObj(state);
    },
    [types.SET_MENUID](state, menuId) {
        state.menuId = menuId;
    },
    [types.SET_SCHOOL_LIST](state, data) {
        state.schoolList = JSON.parse(JSON.stringify(data));
    },
    [types.SET_DICT_LIST](state, data) {
        state.dictList = JSON.parse(JSON.stringify(data));
    },
    // 课程考核方案
    // 新增 
    [types.COURSE_ASSESSMENT_SCHEME.ADD](state,{dialogState, data}) {
        state.courseAssessmentScheme.add.state = dialogState;
        state.courseAssessmentScheme.add.data = data;
    },
    // 编辑
    [types.COURSE_ASSESSMENT_SCHEME.EDIT](state, {dialogState, data}) {
        state.courseAssessmentScheme.edit.state = dialogState;;
        state.courseAssessmentScheme.edit.data = data;
    },
    // 详情
    [types.COURSE_ASSESSMENT_SCHEME.DETAIL](state, {dialogState, data}) {
        state.courseAssessmentScheme.detail.state = dialogState;
        state.courseAssessmentScheme.detail.data = data;;
    },

    // 校历
    // 编辑 
    [types.SCHOOL_CALENDAR.EDIT](state, {dialogState, data}) {
        state.schoolCalendar.edit.state = dialogState;
        state.schoolCalendar.edit.data = data;
    },
    // 详情
    [types.SCHOOL_CALENDAR.DETAIL](state, {dialogState, data}) {
        state.schoolCalendar.detail.state = dialogState;
        state.schoolCalendar.detail.data = data;
    },


    // 流程相关
    // 发起流程
    [types.FLOW.INIT](state, {dialogState, data}) {
        state.flow.init.state = dialogState;
        state.flow.init.data = data;
    },
    // 审批流程
    [types.FLOW.EXAMINE](state, {dialogState, data}) {
        state.flow.examine.state = dialogState;
        state.flow.examine.data = data;
    },
    

    // 教学服务支持计划相关
    // 新增 
    [types.TEACH_SUPPORT.ADD](state, {dialogState, data}) {
        state.teachSupport.add.state = dialogState;
        state.teachSupport.add.data = data;
    },
    // 编辑
    [types.TEACH_SUPPORT.EDIT](state, {dialogState, data}) {
        state.teachSupport.edit.state = dialogState;;
        state.teachSupport.edit.data = data;
    },
    // 详情
    [types.TEACH_SUPPORT.DETAIL](state, {dialogState, data}) {
        state.teachSupport.detail.state = dialogState;
        state.teachSupport.detail.data = data;;
    },


     // 职业发展活动计划相关
    // 新增 
    [types.CAREER_PLAN.ADD](state, {dialogState, data}) {
        state.careerPlan.add.state = dialogState;
        state.careerPlan.add.data = data;
    },
    // 编辑
    [types.CAREER_PLAN.EDIT](state, {dialogState, data}) {
        state.careerPlan.edit.state = dialogState;;
        state.careerPlan.edit.data = data;
    },
    // 详情
    [types.CAREER_PLAN.DETAIL](state, {dialogState, data}) {
        state.careerPlan.detail.state = dialogState;
        state.careerPlan.detail.data = data;;
    },

} 

function initObj(obj) {
    let gettype = Object.prototype.toString;
    for (let key in obj) {
        if (gettype.call(obj[key]) == '[object Object]') {
            initObj(obj[key])
        } else if (gettype.call(obj[key]) == '[object Boolean]') { 
            obj[key] = false;
        } else if (gettype.call(obj[key]) == '[object Array]') { 
            obj[key].splice(0);
        } else {
            obj[key] = null;
        }
        
    } 
}
